#Makefile for uitl/*

CC = gcc

LINKS = mysql_client.o db.o

INCLUDE= -I../../include -I../../http -I../../util -I/usr/local/mysql/include/mysql

LIBRARY= -L/usr/local/mysql/lib/mysql/

#DEFINE = -g -DDEBUG
DEFINE =


TARGET = ../../lib/

%.o: %.cpp
	$(CC) -Wall -O2 ${DEFINE} ${INCLUDE} -c -o $@ $<

all: $(LINKS) mysql.so mysql.a

mysql.so: 
	$(CC) -g -shared -o ${TARGET}/$@ ${LINKS} ../../http/url.o ${LIBRARY} -lmysqlclient -lstdc++

mysql.a:
	ar -rus ${TARGET}/$@ ${LINKS} /usr/local/mysql/lib/mysql/libmysqlclient.a

test:
	${CC} ${DEFINE} -o ../../bin/db_test test.c db.cpp ../../util/queue.c ../../common/log.c ../../common/inifile.c ../../common/url.cpp mysql_client.cpp -I../../include -I../../util -I/usr/local/mysql/include/mysql/ -L/usr/local/mysql/lib/mysql/ -lmysqlclient -lstdc++ -lpthread -lrt

clean:
	rm -f *.o 
